<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品游戏后台管理</title>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <link href="__CSS__/boot.css" rel="stylesheet">
</head>
<body>

    <div style="width: 320px;height:320px; margin: 0 auto;margin-top: 150px" >
        <form>
            <div class="form-group" style="width: 300px">
                <label for="exampleInputEmail1">邮箱</label>
                <input type="email" class="form-control" name="email" id="exampleInputEmail1" placeholder="Email">
            </div>
            <div class="form-group" style="width: 300px">
                <label for="exampleInputPassword1">密码</label>
                <input type="password" class="form-control" name="password" id="exampleInputPassword1" placeholder="Password">
            </div>

            <div class="form-group" style="width: 300px">

                <label for="exampleInputPassword1">验证码</label>
                <input  class="form-control"  placeholder="code" type="text" name="code">
                <img  id="code" src="{:url('index/code')}" onclick="this.src='{:url(\'index/code\')}?id='+Math.random()" width="100" height="50">

            </div>
            <button type="button" class="btn btn-success" onclick="login()">登录</button>&nbsp;&nbsp;&nbsp;&nbsp;
            <button type="button" class="btn btn-warning">重置</button>
        </form>
    </div>

</body>
<script>
    function reg() {
        window.location.href = "{:url('/index/register/index')}";
    }

    function login() {
        var email = $("input[name='email']").val();
        if(!email){
            layer.alert('邮箱不能为空');
            return;
        }
        var password = $("input[name='password']").val();
        if(!password){
            layer.alert('密码不能为空');
            return;
        }
        var code = $("input[name='code']").val();
        if(!code){
            layer.alert('验证码不能为空');
            return;
        }
        $.ajax({
            url:"{:url('index/index/DoLogin')}",
            type:"post",
            data: "email="+email+"&password="+password+"&code="+code,
            datatype:"json",
            success:function(data){
                if(data.success){
                    window.location.href="{:url('/index/examine/index')}";
                }else{
                    layer.alert(data.error);
                    $("#code")[0].onclick();
                }
            },
        });
    }
</script>
</html>